package cn.findviewbydream.evil.main.controller;

import cn.findviewbydream.evil.main.enums.AccessType;
import cn.findviewbydream.evil.main.service.IndexService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/********************************************
 * 工程名：HebeuCS
 * 包名：cn.findviewbydream.evil.main.controller
 * 时间：16-10-28 下午6:52
 * 作者：白雨濃 evil
 * 邮箱：evilbai@foxmail.com
 * 内容：网站首页
 ********************************************/
@Controller
public class IndexController
{
    private final IndexService indexService;

    @Autowired
    public IndexController(IndexService indexService)
    {
        this.indexService = indexService;
    }

    /**
     * 网站入口,判断来访客户端
     *
     * @param request request
     * @param session session
     * @return jsp
     */
    @RequestMapping("/index")
    public String index(HttpServletRequest request, HttpSession session)
    {
        AccessType accessType = indexService.isMobileORie(request, session);
        switch (accessType)
        {
            case PC:
                return "index_main";
            case PC_IE:
                return "index_ie";
            case MOBILE:
                return "index_mobile";
        }
        return "index_main";
    }

    /**
     * 强制进入首页
     *
     * @return jsp
     */
    @RequestMapping("/index/index")
    public String index()
    {
        return "index_main";
    }

    /**
     * 移动用户首页
     *
     * @return jsp
     */
    @RequestMapping("/index/mobile")
    public String index_mobile()
    {
        return "index_mobile";
    }

    /**
     * ie10以下的用户首页
     *
     * @return jsp
     */
    @RequestMapping("/index/ie")
    public String index_ie()
    {
        return "index_ie";
    }

}
